import { typeClassName } from '@/pages/config/classNameMap';
export default{
    methods: {
        // 绑定维护项
        async bindMaintenance (row) {
            this.loading = true;
            if (await this.getRecord({ type: row.type, className: row.className, id: row.id })) {
                if (this.isChecked()) {
                    this.loading = false;
                    return;
                }
                this.paramsSelectionData = this.getSelectionByHierClassName(typeClassName['equipSafeGuardParam'].className)
                this.$set(this.paramSelectPanel.drawer, 'show', true)
                this.loading = false;
            } else {
                this.loading = false;
            }
        },
        // 绑定维护项确定操作
        handleParamSelectSubmit (selection) {
            let pointer = { className: this.className, type: this.type, id: this.classObject.record.id }
            let newData = selection.map(d => {
                return {
                    values: { sf_name: d.label, id: d.id },
                    name: 'equipSafeGuardParam-' + String(d.id),
                    id: d.id,
                    model: typeClassName['equipSafeGuardParam'].modelType,
                    pointer: { id: d.id, className: typeClassName['equipSafeGuardParam'].className, type: typeClassName['equipSafeGuardParam'].type }
                }
            })
            let originalData = [];
            if (!!this.classObject.hier && this.classObject.hier.length > 0) {
                this.classObject.hier[0].basic.forEach(item => {
                    if (item.pointer.className !== typeClassName['equipSafeGuardParam'].className) {
                        originalData.push({ ...item })
                    }
                })
            }
            newData = [...newData, ...originalData]
            // 添加hier中某项的接口
            this.hierAllAddRegister(pointer, newData, this.paramSelectPanel)
        }
    }
}
